<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="pragma" content="no-cache" />
	<link rel="stylesheet" href="/css/style.css" type="text/css"/>
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/util.js"></script>
</head>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////
////  email = "wenpin.qian@happyelements.com"                     ////
////  team = "Athene"                                             ////
////  warnings = "This is generated page,Do Not Modify!";         ////
////  tips = "Opera & IE not supported|Chrome & Safari sugguested"////
//////////////////////////////////////////////////////////////////////
window.returnValue=0;

$(document).ready(function() {
listselectors();
});

function additem() {
	var additemUrl = "/item/add/";
	var nameValue = $("#name").val();
	if(!checkString("名字",nameValue,false)) {
		return;
	}
	var nameParam = "name=" + xparseString(nameValue);
		
	var descValue = $("#desc").val();
	if(!checkString("描述",descValue,false)) {
		return;
	}
	var descParam = "desc=" + xparseString(descValue);
		
	var categoryIdValue = $("#categoryId").val();
	
	var categoryIdParam = "categoryId=" + categoryIdValue;
		
	var typeIdValue = $("#typeId").val();
	
	var typeIdParam = "typeId=" + typeIdValue;
		
	var attackTypeValue = $("#attackType").val();
	
	var attackTypeParam = "attackType=" + attackTypeValue;
		
	var levelValue = $("#level").val();
	if(!checkInteger("等级",levelValue,false)) {
		return;
	}
	var levelParam = "level=" + xparseInt(levelValue);
		
	var qualityIdValue = $("#qualityId").val();
	
	var qualityIdParam = "qualityId=" + qualityIdValue;
		
	var enchantTimeValue = $("#enchantTime").val();
	if(!checkInteger("最大免费强化次数",enchantTimeValue,false)) {
		return;
	}
	var enchantTimeParam = "enchantTime=" + xparseInt(enchantTimeValue);
		
	var bindTypeValue = $("#bindType").val();
	
	var bindTypeParam = "bindType=" + bindTypeValue;
		
	var propsValue = $("#props").val();
	
	var propsParam = "props=" + propsValue;
		
	var propertySetValue = $("#propertySet").val();
	
	var propertySetParam = "propertySet=" + propertySetValue;
		
	var requiredLevelValue = $("#requiredLevel").val();
	if(!checkInteger("英雄等级下限",requiredLevelValue,false)) {
		return;
	}
	var requiredLevelParam = "requiredLevel=" + xparseInt(requiredLevelValue);
		
	var requiredCareerIdValue = $("#requiredCareerId").val();
	
	var requiredCareerIdParam = "requiredCareerId=" + requiredCareerIdValue;
		
	var requiredGenderIdValue = $("#requiredGenderId").val();
	
	var requiredGenderIdParam = "requiredGenderId=" + requiredGenderIdValue;
		
	var uniqueValue = $("#unique").val();
	
	var uniqueParam = "unique=" + uniqueValue;
		
	var maxStackValue = $("#maxStack").val();
	if(!checkInteger("最大叠加数量",maxStackValue,false)) {
		return;
	}
	var maxStackParam = "maxStack=" + xparseInt(maxStackValue);
		
	var recyclingPriceValue = $("#recyclingPrice").val();
	if(!checkInteger("回收价格",recyclingPriceValue,false)) {
		return;
	}
	var recyclingPriceParam = "recyclingPrice=" + xparseInt(recyclingPriceValue);
		
	var canSellValue = $("#canSell").val();
	
	var canSellParam = "canSell=" + canSellValue;
		
	var skillIdValue = $("#skillId").val();
	
	var skillIdParam = "skillId=" + skillIdValue;
		
	var itemresValue = $("#itemres").val();
	
	var itemresParam = "itemres=" + itemresValue;
			
	$.ajax({
		   type: "POST",
		   url: additemUrl,
		   data:   nameParam +'&'+ descParam +'&'+ categoryIdParam +'&'+ typeIdParam +'&'+ attackTypeParam +'&'+ levelParam +'&'+ qualityIdParam +'&'+ enchantTimeParam +'&'+ bindTypeParam +'&'+ propsParam +'&'+ propertySetParam +'&'+ requiredLevelParam +'&'+ requiredCareerIdParam +'&'+ requiredGenderIdParam +'&'+ uniqueParam +'&'+ maxStackParam +'&'+ recyclingPriceParam +'&'+ canSellParam +'&'+ skillIdParam +'&'+ itemresParam ,
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
			       window.returnValue=1;
			       beforeWindowClose();
				   window.close();
			   }else {
				  errDialog(data.message);
			   }
		   }
	});
}

function listselectors() {
var getSkillSelectorUrl = "/special/Skill/getList/";
$.ajax({
		   type: "GET",
		   url: getSkillSelectorUrl,
		   data: "",
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   selectskillId(s2json(data.result));
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
}

function addprops() {
	var propsstr = $("#props").val();
	var returnCallback = function(retvalue) {
		$('#props').val(retvalue);
	}
	openDialog("/pages/core/Array.html",["/pages/customer/PropertyOPEntity.html",propsstr],"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}
function addpropertySet() {
	var propertySetstr = $('#propertySet').val();
	var returnCallback = function(retvalue) {
		$('#propertySet').val(retvalue);
	}
	openDialog("/pages/customer/PropertyOPSet.html",propertySetstr,"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
}
function selectskillId(options) {
	var optionHTML = "";
	for(var i in options) {
		optionHTML = optionHTML + "<option value='"+ options[i][0] +"'>" + options[i][1] + "</option>\n";
	}
	$("#skillId").html(optionHTML);
}

function openResource(fieldname,dependfield) {
	var param = "";
	if(dependfield!="") {
		param = $("#" + dependfield).val()
		if(param == null || param == "") {
			alert("你先把【" + $("#lbl_" + dependfield).html() + "】填了再上传");
			return;
		}
	}
	resourceDialog("item",$("#" + fieldname).val(),param,function(result) {
		if(result != undefined && result != "") {
			$("#" + fieldname).val(result);
		}
	});
}

function beforeWindowClose() {
	if(window.returnCallback) {
		window.returnCallback(window.returnValue);
	}
	window.onbeforeunload = null;
	return true;
}

</script>
<body onunload="beforeWindowClose()">
	<div class="addarea">
	<form action="/item/add" method="post">
		<table>
			<tbody>				
					<tr>					<td>
						<label for="name" id="lbl_name">名字</label>
													<input type="text" id="name" name="name" /><span class="tips">[文字]</span>
											</td>
									
										<td>
						<label for="desc" id="lbl_desc">描述</label>
													<input type="text" id="desc" name="desc" /><span class="tips">[文字]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="categoryId" id="lbl_categoryId">道具大类</label>
																				<select id="categoryId" name="categoryId">
								
									<option value="1">装备类</option>
								
									<option value="2">技能类</option>
								
									<option value="3">商城道具类</option>
								
									<option value="4">碎片类</option>
								
									<option value="5">任务物品类</option>
								
									<option value="6">战利品类</option>
								
									<option value="7">属性道具类</option>
								
									<option value="8">其它类</option>
															</select>
											</td>
									
										<td>
						<label for="typeId" id="lbl_typeId">道具小类</label>
																				<select id="typeId" name="typeId">
								
									<option value="1">武器类</option>
								
									<option value="2">头部防具</option>
								
									<option value="3">铠甲</option>
								
									<option value="4">盾牌</option>
								
									<option value="5">坐骑</option>
								
									<option value="6">时装</option>
								
									<option value="7">技能卡片</option>
								
									<option value="8">碎片</option>
								
									<option value="9">任务物品</option>
								
									<option value="10">战利品</option>
								
									<option value="11">头发</option>
								
									<option value="12">眼睛</option>
								
									<option value="13">眉毛</option>
								
									<option value="14">鼻子</option>
								
									<option value="15">胡子/装饰</option>
								
									<option value="16">嘴巴</option>
								
									<option value="17">礼包</option>
								
									<option value="18">消耗类</option>
								
									<option value="19">宝箱类</option>
								
									<option value="20">精力包</option>
								
									<option value="21">银币包</option>
								
									<option value="22">加速修炼</option>
								
									<option value="23">切磋凭证</option>
															</select>
											</td>
					</tr>				
					<tr>					<td>
						<label for="attackType" id="lbl_attackType">攻击方式</label>
																				<select id="attackType" name="attackType">
								
									<option value="0">不限</option>
								
									<option value="1">砸</option>
								
									<option value="2">戳</option>
								
									<option value="3">投</option>
								
									<option value="4">射</option>
															</select>
											</td>
									
										<td>
						<label for="level" id="lbl_level">等级</label>
													<input type="text" id="level" name="level" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="qualityId" id="lbl_qualityId">品质</label>
																				<select id="qualityId" name="qualityId">
								
									<option value="1">白色</option>
								
									<option value="2">绿色</option>
								
									<option value="3">蓝色</option>
								
									<option value="4">紫色</option>
								
									<option value="5">橙色</option>
															</select>
											</td>
									
										<td>
						<label for="enchantTime" id="lbl_enchantTime">最大免费强化次数</label>
													<input type="text" id="enchantTime" name="enchantTime" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="bindType" id="lbl_bindType">绑定类型</label>
																				<select id="bindType" name="bindType">
								
									<option value="0">不绑定</option>
								
									<option value="1">绑定</option>
								
									<option value="2">拥有后绑定</option>
								
									<option value="3">装备后绑定</option>
								
									<option value="4">使用后绑定</option>
															</select>
											</td>
									
										<td>
						<label for="props" id="lbl_props">道具基础属性</label>
													<input type="text" id="props" name="props" value="[]" disabled/>
							<input type="button" value="..." onclick="addprops()"/>
											</td>
					</tr>				
					<tr>					<td>
						<label for="propertySet" id="lbl_propertySet">道具属性集</label>
													<input type="text" id="propertySet" name="propertySet" value="{}" disabled/>
							<input type="button" value="..." onclick="addpropertySet()"/>
											</td>
									
										<td>
						<label for="requiredLevel" id="lbl_requiredLevel">英雄等级下限</label>
													<input type="text" id="requiredLevel" name="requiredLevel" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="requiredCareerId" id="lbl_requiredCareerId">职业要求</label>
																				<select id="requiredCareerId" name="requiredCareerId">
								
									<option value="0">职业不限</option>
								
									<option value="1">武将</option>
								
									<option value="2">文官</option>
															</select>
											</td>
									
										<td>
						<label for="requiredGenderId" id="lbl_requiredGenderId">性别要求</label>
																				<select id="requiredGenderId" name="requiredGenderId">
								
									<option value="0">性别不限</option>
								
									<option value="1">男</option>
								
									<option value="2">女</option>
															</select>
											</td>
					</tr>				
					<tr>					<td>
						<label for="unique" id="lbl_unique">是否唯一拥有</label>
																				<select id="unique" name="unique">
								
									<option value="0">否</option>
								
									<option value="1">是</option>
															</select>
											</td>
									
										<td>
						<label for="maxStack" id="lbl_maxStack">最大叠加数量</label>
													<input type="text" id="maxStack" name="maxStack" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="recyclingPrice" id="lbl_recyclingPrice">回收价格</label>
													<input type="text" id="recyclingPrice" name="recyclingPrice" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="canSell" id="lbl_canSell">是否可以售卖</label>
																				<select id="canSell" name="canSell">
								
									<option value="0">是</option>
								
									<option value="1">否</option>
															</select>
											</td>
					</tr>				
					<tr>					<td>
						<label for="skillId" id="lbl_skillId">对应技能ID</label>
													<select id="skillId" name="skillId">
							</select>
											</td>
									
										<td>
						<label for="itemres" id="lbl_itemres">资源SWF</label>
													<input type="text" id="itemres" name="itemres" disabled/>
							<input type="button" value="..." onclick="openResource('itemres','typeId')"/><span class="tips">[资源]</span>
											</td>
					</tr>							</tbody>
		</table>
		<input type="button" onclick="additem()" value="添加"/>
	</form>
	</div>
</body>